package com.baibei.ebec.user.messagefollow;

import android.content.Context;

import com.baibei.basic.BasicPresenterImpl;
import com.baibei.ebec.sdk.ApiFactory;
import com.baibei.ebec.sdk.IUserApi;
import com.baibei.model.FollowMessageInfo;
import com.baibei.model.FollowMsgInfo;
import com.baibei.model.MsgNoticeInfo;
import com.baibei.sdk.ApiDefaultObserver;
import com.blankj.utilcode.utils.LogUtils;

import java.util.List;

/**
 * Created by tang on 2018/8/16.
 */

public class MessageFollowPresenterImpl extends BasicPresenterImpl<MessageFollowContract.MessageFollowView> implements MessageFollowContract.Presenter {

    private final IUserApi mUserApi;

    public MessageFollowPresenterImpl(Context context, MessageFollowContract.MessageFollowView view) {
        super(context, view);
        mUserApi = ApiFactory.getInstance().getUserApi();
    }

    @Override
    public void getMsgList(String userId) {
        mView.showLoading();
        createObservable(mUserApi.getFollowMsg(userId)).subscribe(new ApiDefaultObserver<List<FollowMessageInfo>>() {
            @Override
            protected void onError(String s) {

            }

            @Override
            protected void accept(List<FollowMessageInfo> msgNoticeInfos) {
                mView.hideLoading();
                mView.hideRefreshLayout();
                mView.onLoadMsg(msgNoticeInfos);
            }
        });
    }
}
